package com.example.demo2;

public class LightSwitch {

    private String light;

    public void switchRed() {
        if (light.contains("红")) {
            System.out.println("当前的状态就是红灯......");
        } else if (light.contains("绿")) {
            System.out.println("绿灯无法直接切换成红灯");
        } else if (light.contains("黄")) {
            System.out.println("切换成功");
        }
    }


    public void switchGreen() {
        if (light.contains("绿")) {
            System.out.println("当前的状态就是绿灯......");
        } else if (light.contains("红")) {
            System.out.println("红灯无法直接切换成绿灯");
        } else if (light.contains("黄")) {
            System.out.println("切换成功");
        }
    }

    public void switchYellow() {
        if (light.contains("黄")) {
            System.out.println("当前的状态就是黄灯......");
        } else {
            System.out.println("切换成功");
        }
    }


    public String getLight() {
        return light;
    }

    public void setLight(String light) {
        this.light = light;
    }
}
